use DBI;
my  $dbh  = DBI->connect("DBI:mysql:database=school", 'root', '') || die "it broke";
use strict;


open(TMP,'./MAP_School.csv');

while(<TMP>) {
  chomp($_);
  load($_);
}

sub load {
   my $data = shift;

   my (      $cty_dist_school      ,$cty_dist                ,$district_name, $school_code    , $schlname,
             $year                 ,$content_area            ,$grade_level  , $accountable    , $reportable,
             $level_not_determined ,$level_not_determined_pct,$below_basic  , $below_basic_pct, $basic,
             $basic_pct            ,$proficient              ,$proficient_pct, $advanced      , $advanced_pct)
             = split(/,/,$data);

   my $sql  = qq!
         insert into school.map_data
            (
              cty_dist_school      , cty_dist                , district_name, school_code    , schlname,
              year                 , content_area            , grade_level  , accountable    , reportable,
              level_not_determined , level_not_determined_pct, below_basic  , below_basic_pct, basic,
              basic_pct            , proficient              , proficient_pct, advanced      , advanced_pct
            )
          values
            (
               ?, ?, ?, ?, ?,
               ?, ?, ?, ?, ?,
               ?, ?, ?, ?, ?,
               ?, ?, ?, ?, ?
            )
   !; 
   my $sth  = $dbh->prepare($sql);
   $sth->execute(
             $cty_dist_school      ,$cty_dist                ,$district_name, $school_code    , $schlname,
             $year                 ,$content_area            ,$grade_level  , $accountable    , $reportable,
             $level_not_determined ,$level_not_determined_pct,$below_basic  , $below_basic_pct, $basic,
             $basic_pct            ,$proficient              ,$proficient_pct, $advanced      , $advanced_pct
                );
}

